import Vue from 'vue';
import Router from 'vue-router';
const DefaultIndex = {template: '<router-view></router-view>'};

const lazyLoading = (name, index = false) => () => System.import(`@/pages/${name}.vue`);

Vue.use(Router);

export default new Router({
    mode: 'history',
    base: '/admin',
    routes: [
        {
            path: '/login',
            name: 'Login',
            component: lazyLoading('Login'),
        },
        {
            path: '/register',
            name: 'Register',
            component: lazyLoading('Register'),
        },{
            path: '/',
            name: 'Home',
            redirect: {
                name: 'Home.Index',
            },
            component: lazyLoading('Index'),
            children: [
                {
                    path: '/',
                    name: 'Home.Index',
                    // title: '首页',
                    component: lazyLoading('Home/Index'),
                },
                {
                    path: 'application',
                    name: 'Application',
                    title: '应用管理',
                    icon: 'application',
                    component: DefaultIndex,
                    meta:{
                        rank:1
                    },
                    children: [
                        {
                            name: 'Application.Create',
                            path: 'create',
                            title: '创作新应用',
                            meta:{
                                rank:1
                            },
                            component: lazyLoading('Application/Edit'),
                        }, {
                            name: 'Application.ExCreate',
                            path: 'excreate',
                            title: '创作企业专属应用',
                            meta:{
                                roleName:',企业用户,品牌管理员'
                            },
                            component: lazyLoading('Application/ExEdit'),
                        },
                        {
                            name: 'Application.Edit',
                            path: 'edit/:id',
                            // title: '编辑应用',
                            component: lazyLoading('Application/Edit'),
                        },{
                            name: 'Application.ExEdit',
                            path: 'exedit/:id',
                            // title: '编辑应用',
                            component: lazyLoading('Application/ExEdit'),
                        }, {
                            name: 'Application.Finish',
                            path: 'finish',
                            title: '已投稿应用',
                            meta:{
                                rank:1
                            },
                            component: lazyLoading('Application/Index'),
                        }, {
                            name: 'Application.Wait',
                            path: 'wait',
                            //title: '审核中',
                            meta:{
                                rank:1
                            },
                            component: lazyLoading('Application/Index'),
                        }, {
                            name: 'Application.Ready',
                            path: 'ready',
                            title: '私密应用',
                            meta:{
                                rank:1
                            },
                            component: lazyLoading('Application/Index'),
                        },
                    ],
                }, 
                {
                    path: 'message',
                    name: 'Message.Index',
                    component: lazyLoading('Message/Index'),
                }, 
                {
                    path: 'check',
                    name: 'Check',
                    title: '频道管理',
                    icon: 'check',
                    meta:{
                        roleName:'频道管理员'
                    },
                    component: DefaultIndex,
                    children: [
                        {
                            name: 'Check.Wait',
                            path: 'wait',
                            title: '待审核应用',
                            meta:{
                                roleName:'频道管理员'
                            },
                            component: lazyLoading('Check/Index'),
                        }, {
                            name: 'Check.Finish',
                            path: 'finish',
                            title: '已审核应用',
                            meta:{
                                roleName:'频道管理员'
                            },
                            component: lazyLoading('Check/Index'),
                        },
                    ],
                }, 
                {
                    path: 'product',
                    name: 'Product',
                    title: '产品管理',
                    icon: 'product',
                    meta:{
                        rank:1
                    },
                    component: DefaultIndex,
                    children: [
                        {
                            name: 'Product.Into',
                            path: 'into',
                            title: '企业产品入驻',
                            meta:{
                                roleName:',企业用户'
                            },
                            component: lazyLoading('Product/Into'),
                        },
                        {
                            name: 'Product.Into',
                            path: 'into',
                            title: '品牌产品管理',
                            meta:{
                                roleName:',品牌管理员'
                            },
                            component: lazyLoading('Product/Into'),
                        },
                        {
                            name: 'Product.Edit',
                            path: 'edit',
                            title: '产品建档',
                            meta:{
                                rank:1
                            },
                            component: lazyLoading('Product/Edit'),
                        }, {
                            name: 'Product.Index',
                            path: 'index',
                            title: '进度查看',
                            meta:{
                                rank:1
                            },
                            component: lazyLoading('Product/Index'),
                        }, {
                            name: 'Product.Upload',
                            path: 'upload',
                            title: '批量上传',
                            meta:{
                                rank:1
                            },
                            component: lazyLoading('Product/Upload'),
                        },
                    ],
                },
                {
                    path: 'enterprise',
                    name: 'Enterprise',
                    title: '企业档案',
                    meta:{
                        roleName:',企业用户,品牌管理员'
                    },
                    icon: 'help',
                    component: DefaultIndex,
                    children: [
                        {
                            name: 'Enterprise.Introduce',
                            path: 'introduce',
                            title: '企业介绍',
                            meta:{
                                rank:2
                            },
                            component: lazyLoading('Enterprise/Introduce'),
                        },
                    ],
                },
                {
                    path:'count',
                    name:'Count',
                    title:'数据统计',
                    meta:{                        
                        roleName:'企业用户,品牌管理员,超级管理员'
                    },
                    icon:'product',
                    component:DefaultIndex,
                    children:[
                        {
                            path:'Count.Company',
                            name:'company',
                            title:'企业统计',
                            meta:{
                                rank:2
                            },
                            component:lazyLoading('Count/Company')
                        },
                        {
                            path:'Count.Pro',
                            name:'pro',
                            title:'产品统计',
                            meta:{
                                rank:2
                            },
                            component:lazyLoading('Count/Pro')
                        },
                        {
                            path:'Count.Rank',
                            name:'rank',
                            title:'产品排行',
                            meta:{
                                rank:2
                            },
                            component:lazyLoading('Count/Rank')
                        },
                        {
                            path:'Count.ApplySt',
                            name:'applyst',
                            title:'应用统计',
                            meta:{
                                rank:2
                            },
                            component:lazyLoading('Count/ApplySt')
                        },
                        {
                            path:'Count.Apply',
                            name:'apply',
                            title:'应用排行',
                            meta:{
                                rank:2
                            },
                            component:lazyLoading('Count/Apply')
                        }
                    ]

                },{
                    path: 'help',
                    name: 'Help',
                    title: '帮助',
                    icon: 'help',
                    meta:{
                        rank:5
                    },
                    component: DefaultIndex,
                    children: [
                        {
                            name: 'Help.Create',
                            path: 'create',
                            title: '发布帮助',
                            meta:{
                                rank:5
                            },
                            component: lazyLoading('Help/Edit'),
                        }, {
                            name: 'Help.Edit',
                            path: 'edit/:id',
                            // title: '编辑应用',
                            component: lazyLoading('Help/Edit'),
                        }, {
                            name: 'Help.Finish',
                            path: 'finish',
                            title: '帮助列表',
                            meta:{
                                rank:5
                            },
                            component: lazyLoading('Help/Index'),
                        }, 
                        // {
                        //     name: 'Help.Wait',
                        //     path: 'wait',
                        //     title: '审核中',
                        //     component: lazyLoading('Help/Index'),
                        // }, {
                        //     name: 'Help.Ready',
                        //     path: 'ready',
                        //     title: '草稿',
                        //     component: lazyLoading('Help/Index'),
                        // },
                    ],
                },
                {
                    path: 'ad',
                    name: 'ad',
                    title: '广告服务',
                    icon: 'help',
                    meta:{
                        roleName:'品牌管理员,企业用户'
                    },
                    component: DefaultIndex,
                    children: [
                        {
                            name: 'AD.Index',
                            path: 'index',
                            title: '首页展示',
                            meta:{
                                roleName:'品牌管理员,企业用户'
                            },
                            component: lazyLoading('Ad/Index'),
                        }, 
                        {
                            name: 'AD.Filter',
                            path: 'filter',
                            title: '筛选页展示',
                            meta:{
                                roleName:'品牌管理员,企业用户'
                            },
                            component: lazyLoading('Ad/Index'),
                        }, 
                        {
                            name: 'AD.Category',
                            path: 'category',
                            title: '类目排序',
                            meta:{
                                roleName:'品牌管理员,企业用户'
                            },
                            component: lazyLoading('Ad/Index'),
                        },  
                    ],
                },
            ],
        },
    ],
});
